package handler

import (
	"fmt"
	"net/http"

	"github.com/gin-gonic/gin"
)

type MediaData struct {
	VideoCodecs string `json:"videoCodecs,omitempty"`
	Data        string `json:"data,omitempty"`
}

//DefaultHomePageHandler: 处理默认首页
func DefaultHomePageHandler(c *gin.Context) {
	c.Redirect(http.StatusFound, "/static/index.html")
}

func Update(c *gin.Context) {
	formData := c.PostForm("data")
	formVideoCodecs := c.PostForm("codecs")
	formKind := c.PostForm("kind")
	formSize := c.PostForm("size")
	fmt.Println(formData + ",videoCodecs=" + formVideoCodecs + ",kind=" + formKind + ",size=" + formSize)

	var data MediaData
	c.BindJSON(&data)
	fmt.Println("media arrive")
	c.JSON(http.StatusOK, gin.H{
		"code": 1,
	})
}

// func TLSHandler() gin.HandlerFunc {
// 	return func(c *gin.Context) {
// 		secureMiddleware := secure.New(secure.Options{
// 			SSLRedirect: true,
// 			SSLHost:     "0.0.0.0:8081",
// 		})
// 		err := secureMiddleware.Process(c.Writer, c.Request)

// 		if err != nil {
// 			return
// 		}
// 		c.Next()
// 	}
// }
